package com.msb.test16;

import java.io.*;
import java.net.Socket;

public class TestClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("localhost",8080);
        socket.setSoTimeout(5000);
        OutputStream os = socket.getOutputStream();
        DataOutputStream dos = new DataOutputStream(os);
        dos.writeUTF("hello,服务器，我是客户端");

        InputStream is = socket.getInputStream();
        DataInputStream dis = new DataInputStream(is);
        String s = dis.readUTF();
        System.out.println(s);

        dos.close();
        os.close();
        socket.close();

    }
}
